<?php
    session_start();
	$conn = @mysql_connect("localhost","root","lks112700.");
	if(!$conn){
		die("数据库连接失败:".mysql_error());
	}
	mysql_select_db("product",$conn);
	// mysql_query("set character set 'gbk'");
	// mysql_query("ser names 'gbk'");
	$name = $_POST['name'];
	$category = $_POST['category'];
	$year = $_POST['year'];
	$month = $_POST['month'];
	$day = $_POST['day'];
	$phonenum = $_POST['phonenum'];
	$activity = $_POST['activity'];
	$links = $_POST['links'];
	$_SESSION['name'] = $name;
	$_SESSION['category'] = $category;
	$_SESSION['year'] = $year;
	$_SESSION['month'] = $month;
	$_SESSION['day'] = $day;
	$_SESSION['phonenum'] = $phonenum;
	$_SESSION['activity'] = $activity;
	$_SESSION['links'] = $links;
	mysql_query("set names utf8",$conn);
	$file_dir="./image/";
	$file_name=$upload_dir.iconv("utf-8", "gb2312", $_FILES['img']['name']);
	move_uploaded_file($_FILES['img']['tmp_name'], $file_name);
	
	$db2="select id from user where std_tel_num =' $phonenum'";
	$img=mysql_query($db2,$conn);
	$data=mysql_fetch_assoc($img);
	$img_name=$data['id'];
	$img_name="./images/".$img_name.".jpg";
	rename($file_name, $img_name);
	$img_addr = $file_name;
	$db1="INSERT INTO product(name,category,year,month,day,phonenum,activity,links,img_addr) VALUES('$name','$category',$year,'$month','$day','$phonenum','$activity','$links','img_addr')";
	mysql_query($db1,$conn);
	$_SESSION['file_dir'] = $file_name;
?>